package com.cpkso.buss.backend.trade.domain;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.cpkso.buss.backend.user.domain.User;
import com.runze.base.domain.BaseEntity;

/**
 * @author wrzhxy@qq.com
 * @date 2018年3月12日
 */
@Entity
@Table(name="tbBuyerOrder"
	, indexes={@Index(name="idx_buyer_orderid", columnList="order_id")})
@Cache(usage= CacheConcurrencyStrategy.READ_WRITE)
public class TbBuyerOrder extends BaseEntity {
	
	// 淘宝id 必须 淘宝名可能会修改
	@Basic(optional=false)
	@ManyToOne
	@JoinColumn(name="user_id", foreignKey=@ForeignKey(name="FK_tbBuyerOrder_user"))
	private User user;
	
	// 订单id
	@Basic(optional=false)
	@Column(name="order_id", length=50, unique=true)
	private String orderId;
	
	// 下单时间
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="order_time")
	private Date orderTime;
	
	// 订单实际金额
	@Basic(optional=false)
	@Column(name="actual_fee")
	private Double actualFee;
	
	// 商品列表
	// TODO json格式数据存储
	@Lob @Basic(fetch=FetchType.LAZY)
	private String items;
	
	public TbBuyerOrder() {
	}
	// TODO 有参初始化
	public TbBuyerOrder(User user, String orderId, Date orderTime, Double actualFee, String items) {
		this.user = user;
		this.orderId = orderId;
		this.orderTime = orderTime;
		this.actualFee = actualFee;
		this.items = items;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public Double getActualFee() {
		return actualFee;
	}

	public void setActualFee(Double actualFee) {
		this.actualFee = actualFee;
	}

	public String getItems() {
		return items;
	}

	public void setItems(String items) {
		this.items = items;
	}
	
}
